package com.cskaoyan.dbutils;

import com.cskaoyan.bean.Account;
import com.cskaoyan.bean.City;
import com.cskaoyan.connectionpool.dbcp.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

/**
 * 创建日期: 2022/07/28 17:17
 *
 * @author ciggar
 */
public class QueryDemo2 {

//    public static void main(String[] args) throws SQLException {
//
//        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());
//
//        Account account = queryRunner.query("select * from account",
//                new BeanHandler<>(Account.class));
//
//
//        System.out.println(account);
//
//    }


    public static void main(String[] args) throws SQLException {

        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());

        City city = queryRunner.query("select id,name,p_id as pid from city where id = 1001",
                new BeanHandler<>(City.class));

        System.out.println(city);

    }
}
